package com.test.langchain4j.controller;

import dev.langchain4j.model.chat.ChatModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 *
 * @description:
 * @author: liuziyang
 * @since: 2025/7/29 17:11
 * @modifiedBy:
 * @version: 1.0
 */
@RestController
@Slf4j
public class HelloLangchain4JController {
  @Autowired
  @Qualifier("chatModelOpenAI")
  private ChatModel chatModel;

  @Autowired
  @Qualifier("chatModelOllama")
  private ChatModel chatModel2;

  @GetMapping("/langchain4j/hello")
  public String hello(@RequestParam(value = "question", defaultValue = "你是谁") String question) {
    String result = chatModel.chat(question);
    log.info("问答结果: {}", result);
    return result;
  }

  @GetMapping("/langchain4j/hello2")
  public String hello2(@RequestParam(value = "question", defaultValue = "你是谁") String question) {
    String result = chatModel2.chat(question);
    log.info("问答结果: {}", result);
    return result;
  }
}
